package proxyTest.Dyna;

import java.lang.reflect.Proxy;

/**
 * @author zyc
 * @create 2022--05--06 11:49
 */
public class MesProxyFactory {
    public static Object getProxy(Object target) {
        // 目标的类加载器
        ClassLoader classLoader = target.getClass().getClassLoader();
        //目标需要实现的接口
        Class<?>[] interfaces = target.getClass().getInterfaces();
        //代理方法增强
        MesInvocationHandler mesInvocationHandler = new MesInvocationHandler(target);

        Object o = Proxy.newProxyInstance(classLoader, interfaces, mesInvocationHandler);
        return o;
    }
}
